<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "{{%order_item}}".
 *
 * @property integer $id
 * @property string $order_sn
 * @property integer $member_id
 * @property integer $order_total
 * @property integer $status
 */
class OrderItem extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%order_item}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_sn', 'member_id', 'order_total', 'status'], 'required'],
            [['member_id', 'order_total', 'status'], 'integer'],
            [['order_sn'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'order_sn' => 'Order Sn',
            'member_id' => 'Member ID',
            'order_total' => 'Order Total',
            'status' => 'Status',
        ];
    }

    /**
     * @inheritdoc
     * @return OrderItemQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new OrderItemQuery(get_called_class());
    }

    public function getOrderGoodsItem()
    {
        return $this->hasMany(OrderGoodsItem::className(), ['order_id' => 'id']);
    }
}
